|
|
 |
|
|
|
|
Dim M34(1 To 4, 1 To 4) As Single
Dim M1234(1 To 4, 1 To 4) As Single
Dim M56(1 To 4, 1 To 4) As Single
Dim M567(1 To 4, 1 To 4) As Single
' Translate the plane to the origin. m3Translate T, -p1, -p2, -p3
m3Translate Ti, p1, p2, p3
' Rotate around Z-axis until the normal is in
' the Y-Z plane. m3Identity R1
D = Sqr(n1 * n1 + n2 * n2)
R1(1, 1) = n2 / D
R1(1, 2) = nl / D
R1(2, 1) = -R1(1, 2)
R1(2, 2) = R1(1, 1)
m3Identity R1i
R1i(1, 1) = R1(1, 1)
R1i(1, 2) = -R1(1, 2)
R1i(2, 1) = -R1(2, 1)
R1i(2, 2) = R1(2, 2)
' Rotate around the X-axis until the normal
' lies along the Y axis. m3Identity R2
L = Sqr(n1 * n1 + n2 * n2 + n3 * n3)
R2(2, 2) = D / L
R2(2, 3) = -n3 / L
R2(3, 2) = -R2(2, 3)
R2(3, 3) = R2(2, 2)
m3Identity R2i
R2i(2, 2) = R2(2, 2)
R2i(2, 3) = -R2(2, 3)
R2i(3, 2) = -R2(3, 2)
R2i(3, 3) = R2(3, 3)
' Reflect across the X-Z plane. m3Identity S
S(2, 2) = -1
' Combine the matrices. m3MatMultiply M12, T, R1
m3MatMultiply M34, R2, S
m3MatMultiply M1234, M12, M34
m3MatMultiply M56, R2i, R1i
m3MatMultiply M567, M56, Ti
m3MatMultiply M, M1234, M567
End Sub |
|
|
|
|
|